#ifndef SafeHashSet_H_
#define SafeHashSet_H_

#include <hash_set>

#include "Common\stragy\threadsafe\CriticalLock.h"

namespace FURY
{
	namespace CONTAINER
	{
		using FURY::STRAGY::CriticalLock;

		template<typename T>
		class SafeHashSet
		{
			typedef stdext::hash_set<T>	HashSetContainer;
			HashSetContainer	m_container;
			CriticalLock	m_lock;
		public:
			SafeHashSet(void)	{};
			~SafeHashSet(void)	{};

		public:
			void Insert(T obj)
			{
				m_container.insert(obj);
			};

			bool Has(T obj)
			{
				return m_container.find(obj) != m_container.end();
			};

			bool Erase(T obj)
			{
				HashSetContainer::iterator iter = m_container.find(obj);

				if (iter == m_container.end())
					return false;
				else
					m_container.erase(iter);

				return true;
			};

			void Clear(void)
			{
				m_container.clear();
			};

			bool Empty(void)
			{
				return m_container.empty();
			};

			operator CriticalLock&()
			{
				return m_lock;
			};
		};
	};
};

#endif	// SafeHashSet_H_